package project.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import project.DAO.isolateDAO;
import project.DO.isolateDo;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

@Controller
public class isolateController {
    @Autowired
    isolateDAO isolateDao;

    @RequestMapping("isolate1")
    public String isolate1(HttpServletRequest request)
    {
        String address=request.getParameter("address");
        String student=request.getParameter("student");
        String doctor=request.getParameter("doctor");
        String status=request.getParameter("status");
        if(address!=null)
        {
            isolateDao.insertIsolate(address,student,doctor,status);
        }
      return "forward:/isolate";
    }
    @RequestMapping("/isolate2")
    public String isolate2(HttpServletRequest request,Map map)
    {
        String address=request.getParameter("address");
        List<isolateDo> isolateDoList;
        if(address!=null)
        {
            isolateDoList=isolateDao.isolateSelect1(address);
            map.put("isolate",isolateDoList);
        }

        return "isolated";
    }
    @RequestMapping("/isolate")
    public String isolate( Map map)
    {
        List<isolateDo> isolateDoList;
        isolateDoList=isolateDao.isolateSelect();
        map.put("isolate",isolateDoList);
        return "isolated";
    }
}
